package com.blacksheep.mtm.common.utils;

import java.util.Random;

/**
 * @author
 */
public class IDUtil {

    /**
     * 随机id生成
     */
    public static long getRandomId() {
        long millis = System.currentTimeMillis();
        //加上两位随机数
        Random random = new Random();
        int end2 = random.nextInt(99);
        //如果不足两位前面补0
        String str = millis + String.format("%02d", end2);
        long id = new Long(str);
        return id;
    }

    public static long getRandomIdAdd() {
        long millis = System.currentTimeMillis();
        //加上两位随机数
        Random random = new Random();
        int n = (int)(Math.random() * 9000.0D + 1000.0D);
        //如果不足两位前面补0
        String str = millis + String.valueOf(n);
        long id = new Long(str);
        return id;
    }


    public static String getRandomIdStr() {
        long millis = System.currentTimeMillis();
        //加上两位随机数
        Random random = new Random();
        int n = (int)(Math.random() * 9000.0D + 1000.0D);
        //如果不足两位前面补0
        String str = millis + String.valueOf(n);
        return str;
    }
    public static String getRandomIdStr2() {
        long millis = System.currentTimeMillis();
        //加上两位随机数
        Random random = new Random();
        int n = (int)(Math.random() * 8740.0D + 1000.0D);
        //如果不足两位前面补0
        String str = millis + String.valueOf(n);
        return str;
    }
}

